package com.zerosoft.guotai.config;

import lombok.Data;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Component
@Data
@ConfigurationProperties("mqtt")
public class MqttProperties {
    private String hostUrl;
    private String username;
    private String password;
    private String clientId;
//    @Getter
    private Boolean cleanSession;
//    @Getter
    private Boolean reconnect;
    private int timeout;
    private int keepAlive;
    private String defaultTopic;
    private String serverTopic;
    private int qos;

    /**
     * 获取服务器发送主题，格式：server/${env}/report/${topic}
     * @param topic
     * @return
     */
    public String getServerTopic(String topic) {
        return serverTopic + "/" + topic;
    }
}
